package com.sy.dao;


import com.sy.dto.UserDto;
import com.sy.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;


/**
 * @description: 码起 自动生成代码
 * @author: 小毛
 * @create: 2020-11-25 22:00:26
 */
public interface UserDao {
    /*新增*/
    @Insert("insert into user (id,phone,password,username) values(#{id},#{phone},#{password},#{username})")
    int insert(User user);

    /*删除*/
    @Delete("delete from user where id=#{id}")
    int deleteById(int id);
    /*查询全部*/
    @Select("select * from user")
    List<User> all();

    //查找指定手机号
    @Select("select * from t_user where phone=#{phone}")
    User selectByPhone(String phone);

    @Insert("insert into t_user (phone,password,flag) values(#{phone},#{password},1)")
    @Options(useGeneratedKeys = true,keyProperty = "id")//标记获取自增主键的值
    int insertId(User user);

    @Update("update t_user set password=#{password} where phone=#{phone}")
    int update(UserDto dto);
}